
import { HurtType, AttackType, BuffType, DefType, TeamID, TriggerType, UnitType } from "core/typeDefine/typeDefine"
import { FighterSkillModel } from "./skillModel"
import { BuffModel } from "./buffModel"





export class EffectModel {
    id: number
    type: TriggerType
    trigger: FighterModel
    skillID: number
    skillLvl: number
    skillIndex: number
    eSkillID: number
    eSkillLvl: number
    triggerTimes: number
    data: any
    constructor(opts: any = {}) {
        this.id = opts.id || 0
        this.trigger = opts.trigger || null
        this.type = opts.type || null
        this.skillID = opts.skillID || 0
        this.skillLvl = opts.skillLvl || 0
        this.skillIndex = opts.skillIndex || 0
        this.eSkillLvl = opts.eSkillLvl || 0
        this.eSkillLvl = opts.eSkillLvl || 0
        this.data = opts.data || null
        this.triggerTimes = opts.triggerTimes || 0
    }
}

export class CallAttriModel {
    callOtherPer: number
    callAttriPer: number
    attackPer: number
    pAttackPer: number
    lAttackPer: number
    defPer: number
    pDefPer: number
    lDefPer: number
    maxHpPer: number
    hitPer: number
    dodgePer: number
    critPer: number
    call: number[]
    constructor(opts: any = {}) {
        this.callOtherPer = opts.callOtherPer || 0
        this.callAttriPer = opts.callAttriPer || 0
        this.attackPer = opts.attackPer || 0
        this.pAttackPer = opts.pAttackPer || 0
        this.lAttackPer = opts.lAttackPer || 0
        this.defPer = opts.defPer || 0
        this.pDefPer = opts.pDefPer || 0
        this.lDefPer = opts.lDefPer || 0
        this.maxHpPer = opts.maxHpPer || 0
        this.hitPer = opts.hitPer || 0
        this.dodgePer = opts.dodgePer || 0
        this.critPer = opts.critPer || 0
        this.call = opts.call || 0
    }
}

export class FighterAttriModel {
    mainAttriUpPer: number//4维加强属性
    maxHpUpPer: number
    attackUpPer: number
    defUpPer: number
    speedUpPer: number
    reduceMpPer: number
    saveMpPer: number
    startMp: number
    startShieldPer: number


    hp: number
    mp: number
    anger: number //怒气
    shield: number //护盾
    str: number //力量
    con: number  //体质
    agile: number  //敏捷
    spirit: number  //精神
    will: number  //意志 
    maxHp: number //生命
    maxMp: number //魔法
    attackSpeed: number  //攻击速度
    attack: number  //物攻
    pAttack: number  //物攻
    lAttack: number  //法攻
    def: number  //防御
    pDef: number  //物防
    lDef: number //法防
    puncture: number //穿透
    pPuncture: number //物穿
    lPuncture: number //法穿
    hit: number //命中
    dodge: number //闪避
    crit: number //暴击
    scrit: number //技能暴击
    antiCrit: number //抗暴
    antiSCrit: number //技能抗暴
    speed: number //速度
    recoverHp: number //生命恢复
    recoverMp: number //魔法恢复
    attackMp: number //攻击回魔
    skillReduceCdPer: number //技能冷却缩减
    skillReduceAngerPer: number//技能怒耗降低
    antiInjury: number //反伤

    strPer: number //力量%
    conPer: number  //体质%
    agilePer: number  //敏捷%
    spiritPer: number  //精神%
    willPer: number  //意志% 
    maxHpPer: number //生命%
    maxMpPer: number //魔法%
    attackSpeedPer: number  //攻击速度%
    attackPer: number  //物攻%
    pAttackPer: number  //物攻%
    lAttackPer: number  //法攻%
    defPer: number  //防御%
    pDefPer: number  //物防%
    lDefPer: number //法防%
    puncturePer: number //穿透%
    pPuncturePer: number //物穿%
    lPuncturePer: number //法穿%
    hitPer: number //命中%
    dodgePer: number //闪避%
    critPer: number //暴击%
    scritPer: number //技能暴击%
    antiCritPer: number //抗暴%
    antiSCritPer: number //技能抗暴%
    speedPer: number //速度%
    recoverHpPer: number //生命恢复%

    strReducePer: number //力量%
    conReducePer: number  //体质%
    agileReducePer: number  //敏捷%
    spiritReducePer: number  //精神%
    willReducePer: number  //意志% 
    maxHpReducePer: number //生命%
    attackSpeedReducePer: number  //攻击速度%
    attackReducePer: number  //物攻%
    pAttackReducePer: number  //物攻%
    lAttackReducePer: number  //法攻%
    defReducePer: number  //防御%
    pDefReducePer: number  //物防%
    lDefReducePer: number //法防%
    punctureReducePer: number //穿透%
    pPunctureReducePer: number //物穿%
    lPunctureReducePer: number //法穿%
    hitReducePer: number //命中%
    dodgeReducePer: number //闪避%
    critReducePer: number //暴击%
    scritReducePer: number //技能暴击%
    antiCritReducePer: number //抗暴%
    antiSCritReducePer: number //技能抗暴%
    speedReducePer: number //速度%


    hitRate: number //命中率
    dodgeRate: number //闪避率
    critRate: number //暴击率
    antiCritRate: number //抗暴率
    scritRate: number //技能暴击率
    antiScritRate: number //技能抗暴率
    breakDefRate: number //破甲率
    antiBreakDefRate: number //破甲抵抗率
    blockRate: number //格挡率
    antiBlockRate: number //破击率
    controlRate: number //操控率
    antiControlRate: number //操控抵抗率

    poisonRate: number //中毒率   ==
    antiPoisonRate: number //中毒抵抗率
    stunRate: number //眩晕率   ==
    antiStunRate: number //眩晕抵抗率
    bleedRate: number //流血率   ==
    antiBleedRate: number //流血抵抗率
    curseRate: number //诅咒率
    antiCurseRate: number //诅咒抵抗率
    burnRate: number //灼烧率   ==
    antiBurnRate: number //灼烧抵抗率
    freezeRate: number //冰冻率   ==
    antiFreezeRate: number //冰冻抵抗率
    silentRate: number //沉默率   ==
    antiSilentRate: number //沉默抵抗率


    critHurtPer: number //爆伤
    antiCritHurtPer: number //爆伤抵抗
    scritHurtPer: number //爆伤
    antiSCritHurtPer: number //爆伤抵抗
    hurtPer: number //伤害提升
    antiHurtPer: number //伤害减免
    beHurtPer: number  //受到伤害提升
    bePHurtPer: number  //受到物伤害提升
    beLHurtPer: number  //受到法伤害提升
    pHurtPer: number //物伤提升
    lHurtPer: number //法防提升
    antiPHurtPer: number //物伤免疫
    antiLHurtPer: number //法伤免疫
    skillHurtPer: number //技能伤害
    antiSkillHurtPer: number //技能伤害免疫
    doubleAttack: number  //连击
    doubleAttackPer: number  //连击率
    attackBackPer: number //反击率
    recoverPer: number//生命恢复百分比
    reduceRecoverPer: number //降低恢复
    curePer: number //提升治疗效果
    elitePer: number //精英加成
    bloodRate: number //吸血率
    hpHurtPer: number // 造成最大生命百分比的伤害
    recoverCurePer: number
    hpMaxHurtCoe: number // 造成最大生命百分比的伤害系数
    constructor(opts: any = {}) {
        this.mainAttriUpPer = opts.mainAttriUpPer || 0
        this.maxHpUpPer = opts.maxHpUpPer || 0
        this.attackUpPer = opts.attackUpPer || 0
        this.defUpPer = opts.defUpPer || 0
        this.speedUpPer = opts.speedUpPer || 0
        this.reduceMpPer = opts.reduceMpPer || 0
        this.saveMpPer = opts.saveMpPer || 0
        this.startMp = opts.startMp || 0
        this.startShieldPer = opts.startShieldPer || 0

        this.hp = opts.hp || 0
        this.mp = opts.mp || 0
        this.anger = opts.anger || 0 //怒气
        this.shield = opts.shield || 0 //护盾
        this.str = opts.str || 0  //力量
        this.con = opts.con || 0   //体质
        this.agile = opts.agile || 0   //敏捷
        this.spirit = opts.spirit || 0   //精神
        this.will = opts.will || 0   //意志 
        this.maxHp = opts.maxHp || 0 //生命
        this.maxMp = opts.maxMp || 0 //魔法
        this.attackSpeed = opts.attackSpeed || 0   //攻击速度
        this.attack = opts.attack || 0  //物攻
        this.pAttack = opts.pAttack || 0   //物攻
        this.lAttack = opts.lAttack || 0   //法攻
        this.def = opts.def || 0   //防御
        this.pDef = opts.pDef || 0   //物防
        this.lDef = opts.lDef || 0 //法防
        this.puncture = opts.puncture || 0  //穿透
        this.pPuncture = opts.pPuncture || 0  //物穿
        this.lPuncture = opts.lPuncture || 0  //法穿
        this.hit = opts.hit || 0  //命中
        this.dodge = opts.dodge || 0  //闪避
        this.crit = opts.crit || 0  //暴击
        this.scrit = opts.scrit || 0  //技能暴击
        this.antiCrit = opts.antiCrit || 0  //抗暴
        this.antiSCrit = opts.antiSCrit || 0  //技能抗暴
        this.speed = opts.speed || 0  //速度
        this.recoverHp = opts.recoverHp || 0 //生命恢复
        this.recoverMp = opts.recoverMp || 0 //魔法恢复
        this.attackMp = opts.attackMp || 0 //攻击回魔
        this.skillReduceCdPer = opts.skillReduceCdPer || 0 //技能冷却缩减
        this.skillReduceAngerPer = opts.skillReduceAngerPer || 0 //技能怒耗降低
        this.antiInjury = opts.antiInjury || 0 //反伤

        this.strPer = opts.strPer || 0  //力量
        this.conPer = opts.conPer || 0   //体质
        this.agilePer = opts.agilePer || 0   //敏捷
        this.spiritPer = opts.spiritPer || 0   //精神
        this.willPer = opts.willPer || 0   //意志 
        this.maxHpPer = opts.maxHpPer || 0 //生命
        this.maxMpPer = opts.maxMpPer || 0 //魔法
        this.attackSpeedPer = opts.attackSpeedPer || 0   //攻击速度
        this.attackPer = opts.attackPer || 0  //物攻
        this.pAttackPer = opts.pAttackPer || 0   //物攻
        this.lAttackPer = opts.lAttackPer || 0   //法攻
        this.defPer = opts.defPer || 0   //防御
        this.pDefPer = opts.pDefPer || 0   //物防
        this.lDefPer = opts.lDefPer || 0 //法防
        this.puncturePer = opts.puncturePer || 0  //穿透
        this.pPuncturePer = opts.pPuncturePer || 0  //物穿
        this.lPuncturePer = opts.lPuncturePer || 0  //法穿
        this.hitPer = opts.hitPer || 0  //命中
        this.dodgePer = opts.dodgePer || 0  //闪避
        this.critPer = opts.critPer || 0  //暴击
        this.scritPer = opts.scritPer || 0  //技能暴击
        this.antiCritPer = opts.antiCritPer || 0  //抗暴
        this.antiSCritPer = opts.antiSCritPer || 0  //技能抗暴
        this.speedPer = opts.speedPer || 0  //速度
        this.recoverHpPer = opts.recoverHpPer || 0 //生命恢复


        this.strReducePer = opts.strReducePer || 0  //力量
        this.conReducePer = opts.conReducePer || 0   //体质
        this.agileReducePer = opts.agileReducePer || 0   //敏捷
        this.spiritReducePer = opts.spiritReducePer || 0   //精神
        this.willReducePer = opts.willReducePer || 0   //意志 
        this.maxHpReducePer = opts.maxHpReducePer || 0 //生命
        this.attackSpeedReducePer = opts.attackSpeedReducePer || 0   //攻击速度
        this.attackReducePer = opts.attackReducePer || 0  //物攻
        this.pAttackReducePer = opts.pAttackReducePer || 0   //物攻
        this.lAttackReducePer = opts.lAttackReducePer || 0   //法攻
        this.defReducePer = opts.defReducePer || 0   //防御
        this.pDefReducePer = opts.pDefReducePer || 0   //物防
        this.lDefReducePer = opts.lDefReducePer || 0 //法防
        this.punctureReducePer = opts.punctureReducePer || 0  //穿透
        this.pPunctureReducePer = opts.pPunctureReducePer || 0  //物穿
        this.lPunctureReducePer = opts.lPunctureReducePer || 0  //法穿
        this.hitReducePer = opts.hitReducePer || 0  //命中
        this.dodgeReducePer = opts.dodgeReducePer || 0  //闪避
        this.critReducePer = opts.critReducePer || 0  //暴击
        this.scritReducePer = opts.scritReducePer || 0  //技能暴击
        this.antiCritReducePer = opts.antiCritReducePer || 0  //抗暴
        this.antiSCritReducePer = opts.antiSCritReducePer || 0  //技能抗暴
        this.speedReducePer = opts.speedReducePer || 0  //速度


        this.hitRate = opts.hitRate || 0 //命中率
        this.dodgeRate = opts.dodgeRate || 0 //闪避率
        this.critRate = opts.critRate || 0 //暴击率
        this.antiCritRate = opts.antiCritRate || 0 //抗暴率
        this.scritRate = opts.scritRate || 0 //暴击率
        this.antiScritRate = opts.antiScritRate || 0 //技能抗暴率
        this.breakDefRate = opts.breakDefRate || 0 //破甲率
        this.antiBreakDefRate = opts.antiBreakDefRate || 0 //破甲抵抗率
        this.blockRate = opts.blockRate || 0//格挡率
        this.antiBlockRate = opts.antiBlockRate || 0 //破击率
        this.controlRate = opts.controlRate || 0 //操控率
        this.antiControlRate = opts.antiControlRate || 0 //操控抵抗率

        this.poisonRate = opts.poisonRate || 0//中毒率
        this.antiPoisonRate = opts.antiPoisonRate || 0 //中毒抵抗率
        this.stunRate = opts.stunRate || 0//眩晕率
        this.antiStunRate = opts.antiStunRate || 0//眩晕抵抗率
        this.bleedRate = opts.bleedRate || 0//流血率
        this.antiBleedRate = opts.antiBleedRate || 0//流血抵抗率
        this.curseRate = opts.curseRate || 0 //诅咒率
        this.antiCurseRate = opts.antiCurseRate || 0//诅咒抵抗率
        this.burnRate = opts.burnRate || 0//灼烧率
        this.antiBurnRate = opts.antiBurnRate || 0//灼烧抵抗率
        this.freezeRate = opts.freezeRate || 0 //冰冻率
        this.antiFreezeRate = opts.antiFreezeRate || 0//冰冻抵抗率
        this.silentRate = opts.silentRate || 0//沉默率
        this.antiSilentRate = opts.antiSilentRate || 0//沉默抵抗率

        this.critHurtPer = opts.critHurtPer || 0 //爆伤
        this.antiCritHurtPer = opts.antiCritHurtPer || 0 //爆伤抵抗
        this.scritHurtPer = opts.scritHurtPer || 0 //技能暴击
        this.antiSCritHurtPer = opts.antiSCritHurtPer || 0 //技能抗暴
        this.hurtPer = opts.hurtPer || 0 //伤害提升
        this.antiHurtPer = opts.antiHurtPer || 0 //伤害减免
        this.beHurtPer = opts.beHurtPer || 0  //受到伤害提升
        this.bePHurtPer = opts.bePHurtPer || 0  //受到物伤害提升
        this.beLHurtPer = opts.beLHurtPer || 0  //受到法伤害提升
        this.pHurtPer = opts.pHurtPer || 0 //物伤提升
        this.lHurtPer = opts.lHurtPer || 0 //法防提升
        this.antiPHurtPer = opts.antiPHurtPer || 0 //物伤免疫
        this.antiLHurtPer = opts.antiLHurtPer || 0 //法伤免疫
        this.skillHurtPer = opts.skillHurtPer || 0 //技能伤害
        this.antiSkillHurtPer = opts.antiSkillHurtPer || 0 //技能伤害免疫

        this.doubleAttack = opts.doubleAttack || 0  //连击
        this.doubleAttackPer = opts.doubleAttackPer || 0  //连击率
        this.attackBackPer = opts.attackBackPer || 0//反击
        this.recoverPer = opts.recoverPer || 0//生命恢复百分比
        this.reduceRecoverPer = opts.reduceRecoverPer || 0//降低恢复
        this.curePer = opts.curePer || 0//提升治疗效果
        this.elitePer = opts.elitePer || 0 //精英化
        this.bloodRate = opts.bloodRate || 0 //吸血率
        this.recoverCurePer = opts.recoverCurePer || 0 //治疗恢复百分比
        this.hpHurtPer = opts.hpHurtPer || 0 // 造成最大生命百分比的伤害
        this.hpMaxHurtCoe = opts.hpMaxHurtCoe || 0 // 造成最大生命百分比的伤害系数

    }
}

export class FighterModel {
    tid: number //模板id
    teamID: TeamID  //队伍id
    lvl: number //等级
    quality: number //品质
    unitType: UnitType //单位类型
    hurtType: HurtType //攻击类型
    normalAttackData: any //普通攻击配置
    defType: DefType //防御类型
    teamIndexID: number //队伍队员id
    battlePos: number //战斗位置
    angerSkill: FighterSkillModel //怒气技能
    skills: FighterSkillModel[] //技能
    waitSkills: FighterSkillModel[]
    attris: FighterAttriModel //战斗初始属性 
    attrisStr: string //战斗初始属性字符串
    tempAttris: { name: string, value: number, round: number }[] //临时属性 {name:,value, round}
    battleAttris: FighterAttriModel // Attri（初始属性） + buff 
    effects: Map<number, EffectModel[]>
    buffs: BuffModel[]
    power: number //战斗力

    isGetStartShield: boolean

    skillLvls: Map<number, number> //技能等级
    skillCd: number //降低技能cd
    skillCds: Map<number, number> //降低技能cd
    skillCdPers: Map<number, number> //降低技能cd
    skillsHurtPer: Map<number, number> //技能伤害提升
    status: any //状态
    statusHurtPer: any //对状态伤害提升
    statusReduceHurt: any //对状态伤害减免
    callAttri: CallAttriModel
    timerObject: any //定时器
    timers: any[] //定时器数组
    bossTeamIndexID: number //创建的bossid
    monsterHurtPer: any //monster减伤百分比
    monsterIndex: number //monster的index
    occAntiHurtPer: any //职业抗性
    constructor(opts: any = {}) {
        this.tid = opts.tid || 0
        this.teamID = opts.teamID || TeamID.Team1
        this.lvl = opts.lvl || 1
        this.unitType = opts.unitType || UnitType.Partner
        this.quality = opts.quality || 0
        this.hurtType = opts.hurtType || HurtType.Physics
        this.normalAttackData = opts.normalAttackData || null
        this.defType = opts.defType || DefType.Normal
        this.teamIndexID = opts.teamIndexID || 0
        this.battlePos = opts.battlePos || 0
        this.angerSkill = opts.angerSkill || null
        this.skills = opts.skills || []
        this.waitSkills = opts.waitSkills || []
        this.attris = new FighterAttriModel(opts.attris)
        this.tempAttris = opts.tempAttris || []
        this.battleAttris = new FighterAttriModel(opts.battleAttris)
        this.effects = opts.effects || {}
        this.buffs = opts.buffs || []
        this.power = opts.power || 0

        this.isGetStartShield = opts.isGetStartShield || false

        this.skillLvls = opts.skillLvls || {}
        this.skillCd = opts.skillCd || 0
        this.skillCds = opts.skillCds || {}
        this.skillCdPers = opts.skillCdPers || {}
        this.skillsHurtPer = opts.skillsHurtPer || {}
        this.status = opts.status || {}
        this.statusHurtPer = opts.statusHurtPer || {}
        this.statusReduceHurt = opts.statusReduceHurt || {}
        this.callAttri = opts.callAttri || null
        this.timerObject = opts.timerObject || {}
        this.timers = opts.timers || []
        this.bossTeamIndexID = opts.bossTeamIndexID || null
        this.monsterHurtPer = opts.monsterHurtPer || {}
        this.monsterIndex = opts.monsterIndex || 0
        this.occAntiHurtPer = opts.occAntiHurtPer || {}
    }
}